#!/bin/sh

# 等待所有Redis节点启动
echo "等待Redis节点启动..."
sleep 10

# 检查节点是否可用
echo "检查节点连接状态..."
redis-cli -h redis-node-1 -p 7001 ping
redis-cli -h redis-node-2 -p 7002 ping
redis-cli -h redis-node-3 -p 7003 ping

# 创建Redis集群
echo "创建Redis集群..."
redis-cli --cluster create \
  redis-node-1:7001 \
  redis-node-2:7002 \
  redis-node-3:7003 \
  --cluster-replicas 0 \
  --cluster-yes

echo "Redis集群创建完成！"

# 显示集群状态
echo "集群状态："
redis-cli -h redis-node-1 -p 7001 cluster nodes

echo "集群信息："
redis-cli -h redis-node-1 -p 7001 cluster info
